<?php

namespace App\Http\Controllers\home;

use App\Article as ArticleModel;
use App\Category as CategoryModel;
use App\FriendlyLink as FriendlyLinkModel;
use App\Http\Controllers\Controller;
use View;

class Base extends Controller
{
    public function __construct()
    {

        //分类
        $categoryList = CategoryModel::orderBy('sort', 'desc')->where('is_show', '=', 1)->paginate(8);

        //推荐文章
        $recommendArticleList = ArticleModel::orderBy('id', 'desc')->where('is_recommend', '=', 1)->paginate(5);

        //友情
        $friendlyLinkList = FriendlyLinkModel::orderBy('sort', 'desc')->where('is_show', '=', 1)->paginate(10);

        View::share([
            'categoryList'         => $categoryList,
            'recommendArticleList' => $recommendArticleList,
            'friendlyLinkList'     => $friendlyLinkList,
        ]);
    }
}
